package com.xu.cloud.codegenerator.convert;

import com.xu.cloud.codegenerator.pojo.domain.UserInfoDO;
import com.xu.cloud.codegenerator.pojo.http.resp.QueryUserInfoByIdResp;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author xuguan
 * @since 2024/3/11
 */
public class QueryUserInfoByIdRespConverter {
    public static QueryUserInfoByIdResp convertUserInfoDO(UserInfoDO userInfoDo) {
        if (userInfoDo == null) {
            return null;
        }
        final QueryUserInfoByIdResp resp = new QueryUserInfoByIdResp();
        resp.setId(userInfoDo.getId());
        resp.setName(userInfoDo.getName());
        resp.setMobile(userInfoDo.getMobile());
        resp.setAmount(userInfoDo.getAmount());
        return resp;
    }

    public static List<QueryUserInfoByIdResp> convertUserInfoDOList(List<UserInfoDO> userInfoDos) {
        if (userInfoDos == null || userInfoDos.isEmpty()) {
            return new ArrayList<>();
        }
        return userInfoDos.stream()
                .map(QueryUserInfoByIdRespConverter::convertUserInfoDO)
                .collect(Collectors.toList());
    }
}
